using System;

using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;

namespace iDorm
{
	// Model
	// 
	// Container class for any directX rendering data for 3D objects
	public class Model
	{
		private Mesh mesh;
		private Material material;
		private Texture texture;

		string texturefile;

		private Device dev;

		bool textured;
		// Holds properties of 3d models
		// Constructor to create model
		public Model(Device dev, Mesh mesh, Material material, Texture texture, string texturefile)
		{
			this.dev = dev;
			this.mesh = mesh;
			this.material = material;
			this.texture = texture;
			this.texturefile = texturefile;

			textured = true;
		}
		// Renders the model
		public void Render(Matrix world)
		{
			dev.SetTransform(TransformType.World, world);
			dev.Material = material;
			
			if (textured)
                dev.SetTexture(0, texture);
			else
				dev.SetTexture(0, null);

			dev.RenderState.ZBufferEnable = true;
			
			mesh.DrawSubset(0);
		}
		// Allows for texture of model
		public void SelectColor(System.Drawing.Color color, bool textured)
		{
			material.Diffuse = color;
			this.textured = textured;
		}

		public string GetTextureFile()
		{
			return texturefile;
		}
	}
}
 